linux上跑ss,真的很简单
第一步先装docker,CentOS最好是64位的,最好是CentOS7,6的话没试过应该有其他的办法
- 先检查内核版本
$ uname -r
返回的值大于3.10即可。
- 使用 sudo 或 root 权限的用户登入终端。
- 确保yum是最新的
$ yum update
- 安装 docker
yum install docker -y
启动 docker 服务
service docker start chkconfig docker on
拉取 docker 镜像
docker pull oddrationale/docker-shadowsocks
!
运行 docker 镜像
docker run -d -p 12345:12345 oddrationale/docker-shadowsocks -s 0.0.0.0 -p 12345 -k welcome -m aes-256-cfb -d参数允许 docker 常驻后台运行 -p来指定要映射的端口,这里端口号统一保持一致即可。例如:12345 -s服务器 IP 地址,不用动 -k后面设置你的 VPN 的密码,比如:welcome -m指定加密方式
- 运行
docker ps
查看容器是否已成功运行起来了。
docker的常用命令汇总
1、docker的启动、停止、重启
[root@localhost ~]# service docker restart
Redirecting to /bin/systemctl restart docker.service
[root@localhost ~]# service docker stop
Redirecting to /bin/systemctl stop docker.service
[root@localhost ~]# service docker start
Redirecting to /bin/systemctl start docker.service
2、docker创建一个容器
[root@localhost ~]# docker run -it -v /docker_test:/yufei --name yufei_6 centos
[root@724e7701f0d4 /]#
-i:允许我们对容器内的 (STDIN) 进行交互
-t:在新容器内指定一个伪终端或终端
-v:是挂在宿机目录, /docker_test是宿机目录,/yufei是当前docker容器的目录,宿机目录必须是绝对的。
--name:是给容器起一个名字,可省略,省略的话docker会随机产生一个名字
3、docker启动的容器列表
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
724e7701f0d4 centos "/bin/bash" 4 minutes ago Up 4 minutes yufei_6
f9097691663e centos "/bin/bash" 5 minutes ago Up 5 minutes yufei_5
[root@localhost ~]#
4、查看docker创建的所有容器
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
724e7701f0d4 centos "/bin/bash" 5 minutes ago Up 5 minutes yufei_6
f9097691663e centos "/bin/bash" 6 minutes ago Up 6 minutes yufei_5
e59a540fb979 centos "/bin/base" 6 minutes ago Created yufei_4
ff49dfedea4f centos "/bin/bash" 2 hours ago Exited (137) 10 minutes ago yufei_03
d2cc70abb5a5 centos "/bin/bash" 2 hours ago Exited (127) 2 hours ago yufei_02
2d48fc5b7c17 centos "/bin/bash" 2 hours ago Exited (127) 2 hours ago yufei_01
[root@localhost ~]#
5、启动、停止、重启某个docker 容器
[root@localhost ~]# docker start yufei_01
yufei_01
[root@localhost ~]# docker stop yufei_01
yufei_01
[root@localhost ~]# docker restart yufei_01
yufei_01
[root@localhost ~]#
6、查看指定容器的日志记录
[root@back bin]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
baa114bbd3cd oddrationale/docker-shadowsocks "/usr/local/bin/ss..." 28 minutes ago Up 28 minutes 0.0.0.0:9527->9527/tcp eloquent_goldwasser
[root@back bin]# docker logs -f baa114bbd3cd
7、删除某个容器,若正在运行,需要先停止
[root@localhost ~]# docker rm yufei_01
Error response from daemon: You cannot remove a running container 2d48fc5b7c17b01e6247cbc012013306faf1e54f24651d5e16d6db4e15f92d33. Stop the container before attempting removal or use -f
[root@localhost ~]# docker stop yufei_01
yufei_01
[root@localhost ~]# docker rm yufei_01
yufei_01
[root@localhost ~]#
8、删除所有容器
[root@localhost ~]# docker rm $(docker ps -a -q)
Error response from daemon: You cannot remove a running container 724e7701f0d4a830167e21f75b470235a0e408fd6cc2913403426e96f69cba11. Stop the container before attempting removal or use -f
Error response from daemon: You cannot remove a running container f9097691663ee36f9d2ee56afbdcca0eeb8b63e5590ddf18c0c42954c93b9f06. Stop the container before attempting removal or use -f
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker stop yufei_6
yufei_6
[root@localhost ~]# docker stop yufei_5
yufei_5
[root@localhost ~]# docker rm $(docker ps -a -q)
724e7701f0d4
f9097691663e
[root@localhost ~]#
9、镜像
列出镜像:docker image ls
或docker images
列出所有镜像:docker image ls -a
列出所有镜像:docker images -a
查看镜像、容器、数据卷所占用的空间:docker system df
删除镜像:docker image rm